home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Mac OS USB DDK_v1.0.1 / Examples / PrinterClassDriver / DRVRGlue.a < prev    next >
Encoding:
Text File  |  1998-09-03  |  2.4 KB  |  94 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        DRVRGlue.a
  3. ;
  4. ;    Contains:    DRVR interface
  5. ;
  6.  
  7.         
  8.     BLANKS    ON
  9.     STRING    ASIS
  10.         
  11.     INCLUDE        'LowMem.a'
  12.     INCLUDE        'Devices.a'
  13. ;
  14. ;    for an explanation of VMimmune and gestalt see AsyncDriverSample 1.0b4
  15. ;
  16. dVMImmuneMask                EQU    $0001
  17. dDriverGestaltEnableMask    EQU    $0004    ; See DriverGestalt.h
  18.  
  19. drvrFlags        EQU    dReadEnableMask +  dWritEnableMask + dCtlEnableMask +  dStatEnableMask
  20. drvrSystemFlags    EQU dNeedLockMask
  21.  
  22. DRVREntry        MAIN    EXPORT
  23.  
  24.                 IMPORT    DRVROpen, DRVRPrime, DRVRControl, DRVRStatus, DRVRClose
  25.  
  26. Header
  27.         dc.w    drvrFlags + drvrSystemFlags
  28.         DC.W    0        ; no run time
  29.         DC.W    0        ; no events
  30.         DC.W    0        ; no menu
  31.  
  32. ; Entry point offset table to the procs: Open, Prime, Control, Status, Close
  33.         DC.W    MyOpen        - DRVREntry  ; open routine
  34.         DC.W    MyPrime        - DRVREntry  ; prime
  35.         DC.W    MyControl    - DRVREntry  ; control
  36.         DC.W    MyStatus    - DRVREntry  ; status
  37.         DC.W    MyClose        - DRVREntry  ; close
  38.  
  39. ; Title
  40. ;        include three pad bytes so we can re-number the driver
  41.         DC.B    14                    ;Length byte
  42.         DC.B    '.USB--Print---'    ;Pad to odd # of chars, so 1st routine
  43.                                     ;  will be word-aligned.
  44.  
  45. ; Push the address of the routine we wish to call and jump to the glue
  46. ; which sets up the parameters and calls the actual driver implementation
  47. MyOpen        PEA        DRVROpen
  48.             bra.s    MyGlue
  49. MyPrime        PEA        DRVRPrime
  50.             bra.s    MyGlue
  51. MyControl    PEA        DRVRControl
  52.             bra.s    MyGlue
  53. MyStatus    PEA        DRVRStatus
  54.             bra.s    MyGlue
  55. MyClose        PEA        DRVRClose
  56.  
  57. MyGlue
  58.             MOVEM.L    A0/A1,-(A7)                ; save params to the routine
  59.             CLR.W    -(A7)                    ; make room for result
  60.             MOVE.L    A0,-(A7)                ; pass the parameter block
  61.             MOVE.L    A1,-(A7)                ; pass the device control entry
  62.             MOVEA.L    $0012(A7),A0            ; address of routine to jump to
  63.             JSR        (A0)                    ; do it
  64.             MOVE.W    (A7)+,D0                ; get result
  65.             MOVEM.L    (A7)+,A0/A1                ; restore device parameters
  66.             ADDQ.W    #4,A7                    ; pop routine address to clean up
  67. ;            tst.w    IOParam.ioResult(a0)
  68. ;            beq.s    IOComplete
  69.             BTST    #10,IOParam.ioTrap(A0)    ; test for an async call
  70.             BNE.S    Done                    ; if not async, we're done
  71. IOComplete
  72.             SUBQ.W    #4,A7                    ; else get the JIODone vector
  73.             _LMGetJIODone                    ; so we can jump to it.
  74. Done
  75.             RTS        
  76. ;
  77. ;
  78. ;    Change History:
  79. ;        24 Ar 1998,    oja:    pass the error in D0
  80. ;
  81. DRVRDONE    PROC    EXPORT
  82.             
  83.             MOVE.L    4(sp),a0                ; pass the parameter block
  84.             MOVE.L    8(sp),a1                ; pass the device control entry
  85.             MOVE.W    12(sp),d0
  86.             SUBQ.W    #4,A7                    ; get the JIODone vector
  87.             _LMGetJIODone                    ; jump to it.
  88.             
  89.             RTS
  90.  
  91.             ENDPROC
  92.     END
  93.     
  94.